﻿
@{
    ViewBag.Title = "Update";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<script src="~/Content/js/js3city.js"></script>
<script src="~/Content/js/jquery-1.8.2.min.js"></script>
<div class="user-order-box">
    <div class="user-order">
        <div class="home-location-box">
            <div class="goods-location">
                <i><img src=" ~/Content/images/icon/home.png" alt="" width="18" height="18"></i>
                <span><a href="">首页</a></span>
                <span>></span>
                <span><a href="">订单管理</a></span>

            </div>


        </div>

        <div class="user-order-main">
            <!--个人中心左侧栏目-->
            <div class="home-box-left">
                <ul>
                    <h3><i><img src=" ~/Content/images/icon/user-products.png" width="18" alt="18"></i>&nbsp;订单中心</h3>
                    <li><a href="~/Shopping/Index">我的购物车</a></li>
                    <li><a href="~/Order/Index">订单管理</a></li>

                </ul>

                <ul>
                    <h3><i><img src=" ~/Content/images/icon/us.png" width="18" alt="18"></i>&nbsp;会员中心</h3>
                    <li><a href="~/User/Index">个人信息</a></li>
                    <li><a href="~/Address/Index">收货地址</a></li>
                </ul>
            </div>
            <!--个人中心左侧栏目end!-->

            <div class="user-cart-box">
                <div class="user-cart-main">



                    <!--我的地址end!-->
                    <!--新增地址-->


                    <div class="user-addr2">
                        <table width="1050" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="100" align="center">收货人：</td>
                                <td>
                                    <label>
                                        <input type="text" id="Nam" value="@ViewBag.a.Nam" name="textfield" class="user-addr-text" />
                                    </label>
                                </td>
                            </tr>
                        </table>
                    </div>

                    <div class="user-addr2">
                        <table width="1050" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="100" align="center">所在区域：</td>
                                <td>
                                    <select name="sheng" class="user-state-select" id="shen">
                                    </select>
                                    <select name="shi" class="user-state-select" id="city">
                                    </select>
                                    <select name="xian" class="user-state-select" id="xian">
                                    </select>
                                </td>
                            </tr>
                        </table>
                    </div>

                    <div class="user-addr2">
                        <table width="1050" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="100" align="center">街道地址：</td>
                                <td>
                                    <label>
                                        <textarea name="textarea" id="Information">@ViewBag.a.Information</textarea>
                                    </label>
                                </td>
                            </tr>
                        </table>
                    </div>

                    <div class="user-addr2">
                        <table width="1050" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="100" align="center">手机号码：</td>
                                <td>
                                    <label>
                                        <input type="text" name="textfield" id="Phone" value="@ViewBag.a.Phone" class="user-addr-text" />
                                    </label>
                                </td>
                            </tr>
                        </table>
                    </div>

                    <div class="user-addr2">
                        <table width="1050" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="150" align="center">是否为默认地址：</td>
                                <td>
                                    @if (ViewBag.a.IsDefault == "是")
                                    {
                                        <label><input type="radio" name="IsDefault" value="是" checked="checked">是</label>
                                        <label><input type="radio" name="SIsDefaultex" value="否">否</label>
                                    }
                                    else
                                    {
                                        <label><input type="radio" name="IsDefault" value="是">是</label>
                                        <label><input type="radio" name="IsDefault" value="否" checked="checked">否</label>
                                    }
                                </td>
                            </tr>
                        </table>
                    </div>
                    
                    <div class="user-addr2">

                        <button id="btn" class="user-addr-btn">保存添加</button>

                    </div>
                    <input type="hidden" id="CustId" value="@ViewBag.b" />

                    <input type="hidden" id="CreateTime" />
                    <input type="hidden" id="AddId" value="@ViewBag.a.Id" />

                </div>



                <!--新增地址end!-->


            </div>

        </div>

    </div>

</div>
<!--回收站列表end!-->

<script type="text/javascript">
    $("#orderbtn").click(function () {
        $("#tb1").show();
        $("#tb2").hide();
    });
    $(".voidbtn").click(function () {
        $("#tb2").show();
        $("#tb1").hide();

    });

    /*点击标签，背景色改变*/
    $('.order-manager-title a').on('click', function (e) {
        event.preventDefault();
        $(this).css('background', '#363636').siblings().css('background', '#f5a700');

    });


</script>

<!--省市县三级联动js-->
<script type="text/javascript">
    addressInit('shen', 'city', 'xian', '请选择', '请选择', '请选择');
</script>

<script>
    //获取input元素
    var _input = document.getElementById('CreateTime');

    var date = new Date();
    var seperator = "/";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentDate = year + seperator + month + seperator + strDate; //当前日期

    _input.value = currentDate; //赋值给input.value
    _input.setAttribute('disabled', 'disabled'); //不可编辑
</script>



<script>

    $("#btn").click(function () {
        var Id = $("#AddId").val();
        var Nam = $("#Nam").val();
        var Province = $("#shen").val();
        var City = $("#city").val();
        var District = $("#xian").val();
        var Information = $("#Information").val();
        var Phone = $("#Phone").val();
        var IsDefault = $('input[name="IsDefault"]:checked').val();
        var CustId = $("#CustId").val()
        var CreateTime = $("#CreateTime").val()
        $.post("/Address/Update", {
            Id: Id,
            Nam: Nam,
            Province: Province,
            City: City,
            District: District,
            Information: Information,
            Phone: Phone,
            IsDefault: IsDefault,
            CustId: CustId,
            CreateTime: CreateTime
        }, function (res) {
            if (res.Success) {
                alert(res.Message)
                window.location.href = "/Address/Index"
            } else {
                alert(res.Message)
            }

        })
    })


</script>


